import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UsersModule } from './service/HTTPService/users/users.module';
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';
import { EmailModule } from './service/HTTPService/email/email.module';
import { JwtModule } from '@nestjs/jwt';
import { jwtConstants } from './constants/constants';
import { APP_GUARD } from '@nestjs/core';
import { RolesGuard } from './guard/roles.guard';
import { AuthGuard } from './guard/auth.guard';
import { ThrottlerGuard, ThrottlerModule } from '@nestjs/throttler';

import { MyWebSocketModule } from './websocket/websocket.module';


@Module({
  imports: [
    TypeOrmModule.forRoot(
      {
        type: "sqlite",
        database: "user.db",
        autoLoadEntities: true,
        synchronize: true,
        entities: [__dirname + '/**/*.entity{.ts,.js}']

      }
    ),

    JwtModule.register({
      global: true,
      secret: jwtConstants.secret,
      signOptions: { expiresIn: '60d' },
    }),
    ThrottlerModule.forRoot([{
      ttl: 60000,
      limit: 30,
    }]),
    UsersModule,
    EmailModule,
    MyWebSocketModule, //websocket 模块启动



  ],
  controllers: [AppController],
  providers: [
    { provide: APP_GUARD, useClass: AuthGuard },
    AppService,
    { provide: APP_GUARD, useClass: RolesGuard },
    { provide: APP_GUARD, useClass: ThrottlerGuard },
    // MyWebSocketGateway

  ],
})
export class AppModule { }